import java.lang.reflect.Field;

public class shili8 {
    public static void main(String[] args) throws NoSuchFieldException, ClassNotFoundException, InstantiationException, IllegalAccessException {
        Class clz = Class.forName("entity.Person");

        Object person = clz.newInstance();


        Field name = clz.getDeclaredField("name");
        name.setAccessible(true);

        Field id = clz.getDeclaredField("id");
        id.setAccessible(true);
        id.set(person,1);
        System.out.println(id.get(person));


        System.out.println("赋值前的name:"+name.get(person));

        name.set(person,"New Person");
        System.out.println("赋值后的 name:"+name.get(person));


    }
}
